﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Reflection;
using CookComputing.XmlRpc;

namespace MolineSoftware.DrupalXmlRpc.Classes
{
    public static class NodeConverter
    {

        #region Private Methods
        private static String[] attrs = null;
        #endregion


        //public static T Convert2<T>(this XmlRpcStruct xstruct) 
        //    where T : MolineSoftware.DrupalXmlRpc.DrupalNode
        //{
        //    T node = Activator.CreateInstance<T>();
        //    KrmSoftware.ClassExtender extender = new KrmSoftware.ClassExtender(xstruct);
        //    //1. Get T Feilds 
        //    //2. Get T.Fields values and XmlRpcMemberAttribute value
        //    //3. Enumerate throw T and Set values based on XmlRpcMemberAttribute name.

        //    FieldInfo[] fields = xstruct.GetType().GetFields();
        //    MemberInfo[] mi= xstruct.GetType().GetMembers();
            
 
            
        //    //NodeConverter.ClassProperties(xstruct);


        //    //foreach (var d in )
        //    //{
               

        //    //}




        //    return node;
        //}


        ///// <summary>
        ///// Method that returns string[] of class properties
        ///// </summary>
        ///// <returns>string[] of class properties</returns>
        //public static List<Dictionary<string, string>> ClassProperties(this XmlRpcStruct xstruct)
        //{
        //    if (Properties != null && Properties.Count > 0)
        //        return Properties;

        //    if (NodeConverter.Properties == null)
        //        NodeConverter.Properties = new List<Dictionary<string, string>>();
            
        //    try
        //    {
        //        Dictionary<string, string> values; 
        //        int propCount = xstruct.GetType().GetProperties().Count();
        //        int i = 0;

        //        foreach (PropertyInfo pi in xstruct.GetType().GetProperties())
        //        {                    
        //            values = new Dictionary<string,string>();
                    
        //            NodeConverter.Properties.Add(values);
        //            i++;
        //        }

        //        return Properties;
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}

        //public static List<Dictionary<string, string>> Properties {get;set;}//= new List<Dictionary<string, string>>();

    }
}
